#include <bits/stdc++.h>

#define in read()
#define fi first
#define se second
#define pb push_back
#define y1 y_alpha_1

using namespace std;

using ll = long long;
using db = double;
using vec = vector<int>;
using pii = pair<int,int>;

int read() {
	int x = 0; bool f = 0; char ch = getchar();
	while(!isdigit(ch)) f |= ch == '-',ch = getchar();
	while(isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48),ch = getchar();
	return f ? -x : x;
}

const int N = 1e5 + 10;
const int inf = 0x3f3f3f3f;

struct Graph {
	int h[N],cnt;
	struct edge { int v,nxt,pre; } e[N << 1];
	void link(int x,int y) { e[++cnt] = (edge) {y,h[x],0}; e[h[x]].pre = cnt; h[x] = cnt; }
	void del(int x,int d) { e[e[d].pre].nxt = e[d].nxt; e[e[d].nxt].pre = e[d].pre; if(h[x] == d) h[x] = e[d].nxt; }
}G,D;

int n,m; ll a,b; int K;
int d[N],d1[N];
bool vis[N];

int main() {
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,m = in,K = in,a = in,b = in;
	for(int i = 1,u,v;i <= m;i++) u = in,v = in,G.link(u,v),D.link(u,v),G.link(v,u),D.link(v,u);
	queue <int> q; q.push(K); memset(d,0x3f,sizeof d); d[K] = 0;
	while(q.size()) {
		int x = q.front(); q.pop();
		for(int i = G.h[x],y;i;i = G.e[i].nxt)
			if(d[y = G.e[i].v] > d[x] + 1) d[y] = d[x] + 1,q.push(y);
	}
	memset(d1,0x3f,sizeof d1); q.push(K); d1[K] = 0;
	while(q.size()) {
		int x = q.front(); q.pop();
		for(int i = G.h[x],y;i;i = G.e[i].nxt) vis[y = G.e[i].v] = 1;
		for(int i = G.h[x],y;i;i = G.e[i].nxt)
			for(int j = D.h[y = G.e[i].v],yy;j;j = D.e[j].nxt) 
				if(!vis[yy = D.e[j].v]) 
					if(d1[yy] > d1[x] + 1) d1[yy] = d1[x] + 1,q.push(yy),D.del(y,j);
		for(int i = G.h[x],y;i;i = G.e[i].nxt) vis[y = G.e[i].v] = 0;
	}
	for(int i = 1;i <= n;i++) {
		ll ans = inf; if(d[i] < inf) ans = min(ans,min(a * d[i],b * (d[i] >> 1) + (d[i] & 1) * a)); if(d1[i] < inf) ans = min(ans,d1[i] * b);
		printf("%lld\n",ans);
	}
	return 0;
}
